import os
import math
from datetime import datetime
import numpy as np
import cv2
from torchvision.utils import make_grid
from torchvision.transforms import Compose,ToTensor,ToPILImage,Resize,CenterCrop
import random
import torch

def set_random_seed(seed):
    random.seed(seed)
    np.random.seed(seed)
    torch.manual_seed(seed)
    torch.cuda.manual_seed_all(seed)

def display_transform():
    return Compose([
        ToPILImage(),
        Resize(400),
        ToTensor()
    ])

def get_psnr(img1, img2):
   mse = torch.mean((img1/255. - img2/255.)** 2)
   if mse < 1.0e-10:
      return 100
   PIXEL_MAX = 1
   return 20 * math.log10(PIXEL_MAX / math.sqrt(mse))